﻿using Assets.Script.HelpSystem.AtkSystem.AtkObj;
using Assets.Script.HelpSystem.AtkSystem.Base;
using Assets.Script.Human.Player;
using Assets.Script.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

namespace Assets.Script.HelpSystem.AtkSystem.AtkWays
{
    public class AtkWayGunHealing : AtkWay
    {
        AudioClip atkActionClip;
        AudioSource audioSource;

        public AtkWayGunHealing(PlayerBody playerBody, AtkInfo atkInfo, Dictionary<Type, int> bulletEffectLevel,int index) : base(playerBody, atkInfo, bulletEffectLevel,index)
        {

            atkActionClip = Resources.Load<AudioClip>(ResourcePath.Audio.GunShoot);
            audioSource = playerBody.gameObject.AddComponent<AudioSource>();
            audioSource.playOnAwake = false;
            audioSource.clip = atkActionClip;
        }

        protected override void SetData(params object[] o)
        {
            base.SetData(o);
            atkWaitTime = 1f / 2f;
        }

        protected override void AttackStart_m()
        {
            animator.SetFloat("atkSpeed", 1);
        }

        protected override void AttackEnd_m()
        {
            base.AttackEnd_m();
        }

        protected override void UpdateInAttack()
        {
            Attack_Invoke();
        }

        protected override void Attack_Normal()
        {
            var g = GameObject.Instantiate(bullet, playerBody.transform.position, new Quaternion(), null);
            g.GetComponent<Healing>().Init(10, 1, playerBody.PlayerData.BulletData.Atk/2);
        }

    }
}
